const express = require('express')
const app = express()
const port = 3001


// 设置cookie
app.get('/login', (req, res) => {
  res.cookie('jessuonid', '1000001', { maxAge: 2000000, httpOnly: true })
  res.json({ code: 200, message: '登录成功' })
})
// 检测浏览器是否会自动携带上`cookie`
app.get("/getUser", (req, res) => {
  const user = req.headers.cookie.split("=")[1];
  res.json({ code: 200, user });
});
// 静态资源在public目录下
app.use("/", express.static("public"));

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
